package main

import (
	"flag"
	"fmt"
)

/*
用来接收类似 main.go -u root -p 123456 -h localhost -port 3006
*/
func main() {
	var user string
	var password string
	var host string
	var port int

	flag.StringVar(&user, "u", "", "用户名，默认为空")
	flag.StringVar(&password, "p", "", "密码，默认为空")
	flag.StringVar(&host, "h", "", "主机，默认为空")
	flag.IntVar(&port, "port", 3306, "端口号，默认为空")

	flag.Parse() // 必须调用该方法才可以实现参数解析！！！

	fmt.Printf("user = %v, password = %v, host = %v, port = %v", user, password, host, port)

}
